// TextProperties.cpp : implementation file
//

#include "stdafx.h"
#include "resourcemake.h"
#include "TextProperties.h"
#include "resourcemakeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTextProperties dialog


CTextProperties::CTextProperties(CWnd* pParent /*=NULL*/)
	: CDialog(CTextProperties::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTextProperties)
	m_BkMode = FALSE;
	m_Text = _T("");
	//}}AFX_DATA_INIT
}


void CTextProperties::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTextProperties)
	DDX_Control(pDX, IDC_BUTTON_TEXTBG, m_BtnTextBgColor);
	DDX_Control(pDX, IDC_BUTTON_FONTCOLOR, m_BtnFontColor);
	DDX_Check(pDX, IDC_CHECK_BKMODE, m_BkMode);
	DDX_Text(pDX, IDC_EDIT_TEXT, m_Text);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTextProperties, CDialog)
	//{{AFX_MSG_MAP(CTextProperties)
	ON_EN_CHANGE(IDC_EDIT_TEXT, OnChangeEditText)
	ON_BN_CLICKED(IDC_BUTTON_FONTCOLOR, OnButtonFontcolor)
	ON_BN_CLICKED(IDC_BUTTON_TEXTBG, OnButtonTextbg)
	ON_EN_CHANGE(IDC_HREF, OnChangeHref)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTextProperties message handlers

BOOL CTextProperties::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CTextProperties::OnChangeEditText() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	( (CResourcemakeDlg*) AfxGetApp()->m_pMainWnd) ->m_IsSaveSsml = FALSE;

	GetDlgItemText(IDC_EDIT_TEXT,m_Text);
	m_iCurrObj->MyText = m_Text;
	((CResourcemakeDlg *)AfxGetApp()->m_pMainWnd)->m_ddd->save();
	((CResourcemakeDlg *)AfxGetApp()->m_pMainWnd)->m_ddd->Invalidate();
}

void CTextProperties::OnButtonFontcolor() 
{
	// TODO: Add your control notification handler code here
	( (CResourcemakeDlg*) AfxGetApp()->m_pMainWnd) ->m_IsSaveSsml = FALSE;

	CColorDialog dlg(m_TextColor); 
	if (dlg.DoModal()==IDOK)
	{
		m_TextColor=dlg.GetColor();
		CString str_RGB;
		str_RGB.Format("%d:%d:%d",GetRValue(m_TextColor),GetGValue(m_TextColor),GetBValue(m_TextColor));
		this->m_BtnFontColor.SetWindowText(str_RGB);
		m_iCurrObj->MyColor = m_TextColor;
		((CResourcemakeDlg *)AfxGetApp()->m_pMainWnd)->m_ddd->Invalidate();
	}
	
}

void CTextProperties::OnButtonTextbg() 
{
	// TODO: Add your control notification handler code here
	CColorDialog dlg(m_bgColor); 
	if (dlg.DoModal()==IDOK)
	{
		m_bgColor=dlg.GetColor();
		CString str_RGB;
		str_RGB.Format("%d:%d:%d",GetRValue(m_bgColor),GetGValue(m_bgColor),GetBValue(m_bgColor));
		this->m_BtnTextBgColor.SetWindowText(str_RGB);
		m_iCurrObj->BgColor = m_bgColor;
		((CResourcemakeDlg *)AfxGetApp()->m_pMainWnd)->m_ddd->Invalidate();
	}	
}

void CTextProperties::OnChangeHref() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	( (CResourcemakeDlg*) AfxGetApp()->m_pMainWnd) ->m_IsSaveSsml = FALSE;

	GetDlgItemText(IDC_HREF,m_Href);
	m_iCurrObj->href = m_Href;	
}
